<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>校车考勤</title>
	<link rel="stylesheet" href="../css/common2.css">
	<style>
		.search_img {
			position: absolute;
			right: 3%;
		}

		.other {
			height: 33px;
			max-width: 120px;
			width: 15vw;
			height: 35px;
			padding-left: 20px;
			font-size: 14px;
			color: #686868;
			position: absolute;
			border: 1px solid;
			display: inline-block;
			width: 65px;
			font-size: 12px;
			position: absolute;
			padding-left: 5px;
		}
	</style>
</head>

<body>
	<div id="vue-root">
		<div class="refresh action-buttons" onclick="location.reload()">刷新</div>
		<input placeholder="请输入车牌号" class="ui-select search" v-model="search.plate"
			style="position: absolute; right: 545px; max-width: 120px;height: 33px;">

		<input placeholder="请输入学生姓名" class="search search_student" v-model="search.name"
			style="position: absolute; right: 400px; max-width: 120px;height: 33px;">

		<select class="search class" v-model="search.classesId" style="position: absolute; right: 250px;">
			<option :value="undefined">请选择班级</option>
			<option v-for="classes in classess" :key="classes.id" :value="classes.id" v-text="classes.name">
			</option>
		</select>

		<input placeholder="开始时间" class="other" v-model="search.startTime" id="startTime" style=" right: 170px">
		<input placeholder="结束时间" class="other" v-model="search.endTime" id="endTime"
			style=" right: 100px; border-left: none;">

		<img src="../image/search.png" height="35" width="35" class="search_img" @click="getData0">

		<div class="center">
			<div class="table">
				<table class="table_top">
					<thead>
						<tr>
							<th>
								<input type="checkbox" class="check-box" v-model="all">序号
							</th>
							<th>考勤车辆</th>
							<th>卡号ID</th>
							<th>姓名</th>
							<th>班级</th>
							<!-- <th>考勤站点</th> -->
							<th>考勤时间</th>
							<th>拍照</th>
							<th>体温</th>
							<th>进出状态</th>
							<th>删除</th>
						</tr>
					</thead>
					<tbody id="list">
						<tr v-for="(attendance,index) in list" :key="attendance.id">
							<td>
								<input type="checkbox" class="check-box" v-model="attendance.checked">
								<span v-text="index+1"></span>
							</td>
							<td v-text="attendance.plate"></td>
							<td v-text="attendance.cardNo"></td>
							<td v-text="attendance.holder"></td>
							<td v-text="attendance.classesName"></td>
							<!-- <td>华南碧桂园站</td> -->
							<td v-text="format(attendance.time)"></td>
							<td class="two photo">
								<img v-for="pic in pics(attendance.pic)" :src="getImg(pic)" alt="" @click="bigImg(pic)">
							</td>
							<td v-text="attendance.temperature"></td>
							<td v-text="['正常','异常','上车','下车'][attendance.status]"></td>
							<td>
								<div class="option">
									<div class="delete-icon option-icon" @click="del([attendance.id])"
										style="left: 20%; top:30%;position: absolute;">
										<img class="img" src="../image/delete.png" height="20" width="20"
											onmouseover="this.src='../image/delete_light.png'"
											onmouseout="this.src='../image/delete.png'" />
									</div>
								</div>
							</td>
						</tr>

					</tbody>
				</table>
			</div>
		</div>

		<div class="delete" @click="batchDelete" v-if="total>1">批量删除</div>
		<div class="delete export" @click="exports">批量导出</div>
		<ul class="pagination" v-if="pages>1">
			<li>
				<a v-if="pageNum!=1" @click="pageNum=1">«</a>
				<a class="pages-jump" v-if="pageNum!=1" @click="pageNum--">‹</a>
				<a v-text="pageNum"></a>
				<a class="pages-jump" v-if="pageNum!=pages" @click="pageNum++">›</a>
				<a v-if="pageNum!=pages" @click="pageNum=pages">»</a>
			</li>
		</ul>
		<div v-if="bigimg" @click="bigimg=false">
			<div class="img_layer"></div>
			<img :src="big_src" class="big_Img">
		</div>
	</div>


	<script src="/scriptZIP/qs.min.js"></script>
	<script src="/scriptZIP/vue.min.js"></script>
	<script src="/scriptZIP/axios.min.js"></script>

	<script src="/scriptZIP/dayjs.min.js"></script>

	<script src="/scriptZIP/dayjs.min.js"></script>


	<script src="/lib/laydate/laydate.js"></script>

	<script src="/js/common.js"></script>
	<script src="/js/list.js"></script>

	<script>
		var app = new Vue(merge({
			data: {
				classess: [],
				search: {},
				urls: {
					del: '/pc/attendance/del'
				},
				bigimg: false,
				big_src: null,
				show: false,
				date: null
			},
			created: function () {
				var schoolId = top_params().id;
				if (!schoolId) {
					alert('未知学校');
					throw '未知学校';
				}
				this.schoolId = schoolId;
				axios.get('/pc/classes/all/' + schoolId).then(function (res) {
					this.classess = res.data;
				}.bind(this));
				this.urls.list = '/pc/bus/attendance/list/' + schoolId;
				this.getData();
			},
			methods: {
				format: function (time) {
					if (!time) return null;
					return dayjs(time).format('YYYY-MM-DD HH:mm:ss');
				},
				getImg: function (pic) {
					if (!pic) return null;
					return '/static/' + this.schoolId + '/attendance/' + pic;
				},
				bigImg: function (pic) {
					this.big_src = this.getImg(pic);
					this.bigimg = true;
				},
				exports: function () {
					var q = Qs.stringify(this.search);
					if (q) q = '?' + q;
					location.href = '/pc/bus/attendance/export/' + this.schoolId + q;
				},
				pics: function (pics) {
					if (!pics) return [];
					return pics.split(',');
				},
				exports: function () {
					var q = Qs.stringify(this.search);
					if (q) q = '?' + q;
					location.href = '/pc/bus/attendance/export/' + this.schoolId + q;
				},
			},
			watch: {
				show: function (newValue, oldValue) {
					if (newValue) {
						this.$nextTick(function () {
							laydate.render({
								elem: '#layday',
								type: 'datetime',
								done: function (value, date, endDate) {
									this.date = value;
								}.bind(this)
							});
						}.bind(this));
					}
				},
				'search.only': function (newValue, oldValue) {
					if (newValue) this.search.classesId = null;
				},
				'search.classesId': function (newValue, oldValue) {
					if (newValue && this.search.only) this.search.only = null;
				}
			}
		}));

		laydate.render({
			elem: '#startTime',
			type: 'datetime',
			done: function (value, date, endDate) {
				app.search.startTime = value;
			}
		});

		laydate.render({
			elem: '#endTime',
			type: 'datetime',
			done: function (value, date, endDate) {
				app.search.endTime = value;
			}
		});
	</script>


</body>

</html>